package com.wdd.web.defaultt.controller;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageHelper;
import com.wdd.web.defaultt.entity.UserEntity;
import com.wdd.web.defaultt.mapper.UserMapper;
import com.wdd.web.defaultt.mapper.UserMapperXml;

@RestController
public class UserControllerXml {
	
	@Autowired
	private UserMapperXml userMapperXml;//mybatyis xml配置文件

	
	@Value("${www}")
	public String www;//测试读取配置文件
	
    @RequestMapping("/getOne")
    public UserEntity getUser(Long id) {
    	UserEntity user=userMapperXml.getOne(id);
        return user;
    }
    
    @RequestMapping("/getAllUser")
    public List<UserEntity> getAllUser(Long id) {
    	PageHelper.startPage(2,3);
    	List<UserEntity> user=userMapperXml.getAllUser();
        return user;
    }
    
    @RequestMapping("/add")
    public String save(UserEntity user) {
    	userMapperXml.insert(user);
    	return "success";
    }
	/**
	 * 测试读取配置文件
	 * @return
	 */
	@GetMapping("/www")
	public String www(){
		return www;
	}
    
    
}